package com.cjm.algorithm.leetcode;

import java.util.Arrays;

public class Ti136 {
    public static int singleNumber(int[] nums) {
        Arrays.sort(nums);
        Integer before = null;
        for (int i = 0; i <nums.length; i++) {
            int cur = nums[i];
            if (before == null) {
                before = cur;
                continue;
            }
            if (before == cur) {
                before = null;
            } else {
                return before;
            }
        }
        return before;
    }

    public static void main(String[] args) {
        int i = singleNumber(new int[]{2, 2, 1});
        int j = singleNumber(new int[]{4, 1, 2, 1, 2});
        System.err.println("OK");
    }
}
